package com.cjx.AOP;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

/**
 * @author cjx
 * @date 2021/3/25 0025 - 18:05
 */
@Aspect
@Component
public class BookProxy {

    @Before(value = "execution(* com.cjx.Controller..*.aad*(..))")
    public void test1() {
        System.out.println("befor:" + System.currentTimeMillis());

    }

    @Around(value = "execution(* com.cjx.Controller..*.add*(..))")
    public Object test(ProceedingJoinPoint ProceedingJoinPoint) throws Throwable {
        Object result = null;

        long begin = System.currentTimeMillis();


        result = ProceedingJoinPoint.proceed();


        long end = System.currentTimeMillis();

        System.out.println("begin:" + begin);

        System.out.println(end - begin + "ms");
        return result;
    }

}
